{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pyecharts import Bar,Pie\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import  matplotlib.pyplot as  plt\n",
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "df=pd.read_excel(\"all_data_meituan.xlsx\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": true,
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>anonymous</th>\n",
       "      <th>avgPrice</th>\n",
       "      <th>commentTime</th>\n",
       "      <th>dealEndtime</th>\n",
       "      <th>did</th>\n",
       "      <th>menu</th>\n",
       "      <th>picUrls</th>\n",
       "      <th>quality</th>\n",
       "      <th>readCnt</th>\n",
       "      <th>replyCnt</th>\n",
       "      <th>reviewId</th>\n",
       "      <th>star</th>\n",
       "      <th>userId</th>\n",
       "      <th>userLevel</th>\n",
       "      <th>userName</th>\n",
       "      <th>userUrl</th>\n",
       "      <th>zanCnt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>False</td>\n",
       "      <td>73</td>\n",
       "      <td>1525875708515</td>\n",
       "      <td>1.530338e+09</td>\n",
       "      <td>44328533</td>\n",
       "      <td>单人午晚餐</td>\n",
       "      <td>[{'id': -1445845615, 'url': 'http://p0.meituan...</td>\n",
       "      <td>True</td>\n",
       "      <td>25434</td>\n",
       "      <td>0</td>\n",
       "      <td>1674208634</td>\n",
       "      <td>40</td>\n",
       "      <td>291754497</td>\n",
       "      <td>1</td>\n",
       "      <td>q哈哈哈qq</td>\n",
       "      <td>https://img.meituan.net/avatar/92de6ba9a330efe...</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>False</td>\n",
       "      <td>73</td>\n",
       "      <td>1527853291658</td>\n",
       "      <td>1.530338e+09</td>\n",
       "      <td>44328241</td>\n",
       "      <td>2人午晚餐</td>\n",
       "      <td>[{'id': -1429563625, 'url': 'http://p0.meituan...</td>\n",
       "      <td>False</td>\n",
       "      <td>7293</td>\n",
       "      <td>0</td>\n",
       "      <td>1693519286</td>\n",
       "      <td>40</td>\n",
       "      <td>829297130</td>\n",
       "      <td>2</td>\n",
       "      <td>love勇往直前</td>\n",
       "      <td>https://img.meituan.net/avatar/095e2339acd2e50...</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   anonymous  avgPrice    commentTime   dealEndtime       did   menu  \\\n",
       "0      False        73  1525875708515  1.530338e+09  44328533  单人午晚餐   \n",
       "1      False        73  1527853291658  1.530338e+09  44328241  2人午晚餐   \n",
       "\n",
       "                                             picUrls  quality  readCnt  \\\n",
       "0  [{'id': -1445845615, 'url': 'http://p0.meituan...     True    25434   \n",
       "1  [{'id': -1429563625, 'url': 'http://p0.meituan...    False     7293   \n",
       "\n",
       "   replyCnt    reviewId  star     userId  userLevel  userName  \\\n",
       "0         0  1674208634    40  291754497          1    q哈哈哈qq   \n",
       "1         0  1693519286    40  829297130          2  love勇往直前   \n",
       "\n",
       "                                             userUrl  zanCnt  \n",
       "0  https://img.meituan.net/avatar/92de6ba9a330efe...       2  \n",
       "1  https://img.meituan.net/avatar/095e2339acd2e50...       0  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.drop('comment',axis=1).head(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "73    17400\n",
       "Name: avgPrice, dtype: int64"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['avgPrice'].value_counts()\n",
    "# 同一家店的均价应该为同一个数值，所以这列数据没多大的意义"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False    14402\n",
       "True      2998\n",
       "Name: anonymous, dtype: int64"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['anonymous'].value_counts()\n",
    "# 匿名评价与实名评价的比例大致在5:1左右"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    2018-05-09 22:21:48\n",
       "1    2018-06-01 19:41:31\n",
       "2    2018-04-04 11:52:23\n",
       "3    2018-05-01 17:12:22\n",
       "4    2018-05-17 16:48:04\n",
       "Name: commentTime, dtype: object"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def convertTime(x):\n",
    "    y=time.localtime(x/1000)\n",
    "    z=time.strftime(\"%Y-%m-%d %H:%M:%S\",y)\n",
    "    return z\n",
    "df[\"commentTime\"]=df[\"commentTime\"].apply(convertTime)\n",
    "df[\"commentTime\"].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False    17223\n",
       "True       177\n",
       "Name: dealEndtime, dtype: int64"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 在excel可以用筛选器直接看到这列中的数据含有缺失值，或者在拿到数据的时候，使用df.info() 查看每列的数据信息情况\n",
    "df['dealEndtime'].isna().value_counts()\n",
    "# 这列数据中含有177个缺失值，其余完整"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"64f1b3c3bf0d48d9b18ad884c5cc8744\" style=\"width:1000px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_64f1b3c3bf0d48d9b18ad884c5cc8744 = echarts.init(document.getElementById('64f1b3c3bf0d48d9b18ad884c5cc8744'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_64f1b3c3bf0d48d9b18ad884c5cc8744 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6309\\u6708\\u7edf\\u8ba1\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"magicType\": {\n",
       "                \"show\": true,\n",
       "                \"type\": [\n",
       "                    \"line\",\n",
       "                    \"bar\",\n",
       "                    \"stack\",\n",
       "                    \"tiled\"\n",
       "                ],\n",
       "                \"title\": {\n",
       "                    \"line\": \"\\u6298\\u7ebf\\u56fe\",\n",
       "                    \"bar\": \"\\u67f1\\u72b6\\u56fe\",\n",
       "                    \"stack\": \"\\u5806\\u53e0\",\n",
       "                    \"tiled\": \"\\u5e73\\u94fa\"\n",
       "                }\n",
       "            },\n",
       "            \"dataZoom\": {\n",
       "                \"show\": true,\n",
       "                \"title\": {\n",
       "                    \"zoom\": \"\\u533a\\u57df\\u7f29\\u653e\",\n",
       "                    \"back\": \"\\u7f29\\u653e\\u8fd8\\u539f\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 6402351,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u6309\\u6708\\u7edf\\u8ba1\",\n",
       "            \"data\": [\n",
       "                7.0,\n",
       "                4.0,\n",
       "                53.0,\n",
       "                359.0,\n",
       "                2466.0,\n",
       "                4169.0,\n",
       "                2759.0,\n",
       "                2490.0,\n",
       "                2754.0,\n",
       "                2199.0,\n",
       "                140.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 6402351\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u6309\\u6708\\u7edf\\u8ba1\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2017-08\",\n",
       "                \"2017-09\",\n",
       "                \"2017-10\",\n",
       "                \"2017-11\",\n",
       "                \"2017-12\",\n",
       "                \"2018-01\",\n",
       "                \"2018-02\",\n",
       "                \"2018-03\",\n",
       "                \"2018-04\",\n",
       "                \"2018-05\",\n",
       "                \"2018-06\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ],\n",
       "    \"dataZoom\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"type\": \"slider\",\n",
       "            \"start\": 50,\n",
       "            \"end\": 100,\n",
       "            \"orient\": \"horizontal\"\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "myChart_64f1b3c3bf0d48d9b18ad884c5cc8744.setOption(option_64f1b3c3bf0d48d9b18ad884c5cc8744);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x1b928835438>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['commentTime']=pd.to_datetime(df['commentTime'])\n",
    "df1 = df.set_index('commentTime')\n",
    "df1.resample('D').size().sort_values(ascending=False).head(100)\n",
    "df2=df1.resample('M').size().to_period()\n",
    "df2=df2.reset_index()\n",
    "# df2.columns\n",
    "# from pyecharts import  Bar\n",
    "bar =Bar(\"按月统计\",width=1000,height=400)\n",
    "bar.add(\"按月统计\",df2['commentTime'],df2[0],is_label_show=True, is_datazoom_show=True,is_toolbox_show=True,is_more_utils=True)\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"f4f62b9515f442e89b6b765a818eb307\" style=\"width:1000px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_f4f62b9515f442e89b6b765a818eb307 = echarts.init(document.getElementById('f4f62b9515f442e89b6b765a818eb307'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_f4f62b9515f442e89b6b765a818eb307 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6309\\u65f6\\u7edf\\u8ba1\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"magicType\": {\n",
       "                \"show\": true,\n",
       "                \"type\": [\n",
       "                    \"line\",\n",
       "                    \"bar\",\n",
       "                    \"stack\",\n",
       "                    \"tiled\"\n",
       "                ],\n",
       "                \"title\": {\n",
       "                    \"line\": \"\\u6298\\u7ebf\\u56fe\",\n",
       "                    \"bar\": \"\\u67f1\\u72b6\\u56fe\",\n",
       "                    \"stack\": \"\\u5806\\u53e0\",\n",
       "                    \"tiled\": \"\\u5e73\\u94fa\"\n",
       "                }\n",
       "            },\n",
       "            \"dataZoom\": {\n",
       "                \"show\": true,\n",
       "                \"title\": {\n",
       "                    \"zoom\": \"\\u533a\\u57df\\u7f29\\u653e\",\n",
       "                    \"back\": \"\\u7f29\\u653e\\u8fd8\\u539f\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 7220158,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u6309\\u65f6\\u7edf\\u8ba1\",\n",
       "            \"data\": [\n",
       "                419.0,\n",
       "                154.0,\n",
       "                8.0,\n",
       "                40.0,\n",
       "                20.0,\n",
       "                15.0,\n",
       "                49.0,\n",
       "                107.0,\n",
       "                455.0,\n",
       "                665.0,\n",
       "                1068.0,\n",
       "                1471.0,\n",
       "                1176.0,\n",
       "                1275.0,\n",
       "                1046.0,\n",
       "                929.0,\n",
       "                972.0,\n",
       "                1093.0,\n",
       "                1331.0,\n",
       "                1560.0,\n",
       "                1225.0,\n",
       "                979.0,\n",
       "                694.0,\n",
       "                649.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 7220158\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u6309\\u65f6\\u7edf\\u8ba1\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"0 h\",\n",
       "                \"1 h\",\n",
       "                \"2 h\",\n",
       "                \"3 h\",\n",
       "                \"4 h\",\n",
       "                \"5 h\",\n",
       "                \"6 h\",\n",
       "                \"7 h\",\n",
       "                \"8 h\",\n",
       "                \"9 h\",\n",
       "                \"10 h\",\n",
       "                \"11 h\",\n",
       "                \"12 h\",\n",
       "                \"13 h\",\n",
       "                \"14 h\",\n",
       "                \"15 h\",\n",
       "                \"16 h\",\n",
       "                \"17 h\",\n",
       "                \"18 h\",\n",
       "                \"19 h\",\n",
       "                \"20 h\",\n",
       "                \"21 h\",\n",
       "                \"22 h\",\n",
       "                \"23 h\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#bda29a\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#444693\",\n",
       "        \"#749f83\",\n",
       "        \"#6d8346\",\n",
       "        \"#f6f5ec\",\n",
       "        \"#905a3d\",\n",
       "        \"#c23531\",\n",
       "        \"#f05b72\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#1d953f\",\n",
       "        \"#ac6767\",\n",
       "        \"#6e7074\",\n",
       "        \"#2a5caa\",\n",
       "        \"#6950a1\",\n",
       "        \"#61a0a8\",\n",
       "        \"#726930\",\n",
       "        \"#fab27b\",\n",
       "        \"#d48265\",\n",
       "        \"#ca8622\",\n",
       "        \"#918597\",\n",
       "        \"#546570\",\n",
       "        \"#b2d235\",\n",
       "        \"#2f4554\"\n",
       "    ],\n",
       "    \"dataZoom\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"type\": \"slider\",\n",
       "            \"start\": 50,\n",
       "            \"end\": 100,\n",
       "            \"orient\": \"horizontal\"\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "myChart_f4f62b9515f442e89b6b765a818eb307.setOption(option_f4f62b9515f442e89b6b765a818eb307);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x1b927ed7cc0>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['commentTime']=pd.to_datetime(df['commentTime'])\n",
    "df['hour'] = df['commentTime'].dt.hour\n",
    "df2= df.groupby(['hour']).size()\n",
    "df2\n",
    "from pyecharts import  Bar\n",
    "bar =Bar(\"按时统计\",width=1000,height=400)\n",
    "bar.add(\"按时统计\",['{} h'.format(i) for i in df2.index],df2.values,is_label_show=True, is_datazoom_show=True,is_toolbox_show=True,is_more_utils=True,is_random=True)\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"732f4d7fd79c46989fb4329e905232a0\" style=\"width:1000px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_732f4d7fd79c46989fb4329e905232a0 = echarts.init(document.getElementById('732f4d7fd79c46989fb4329e905232a0'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_732f4d7fd79c46989fb4329e905232a0 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6309\\u5929\\u7edf\\u8ba1\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"magicType\": {\n",
       "                \"show\": true,\n",
       "                \"type\": [\n",
       "                    \"line\",\n",
       "                    \"bar\",\n",
       "                    \"stack\",\n",
       "                    \"tiled\"\n",
       "                ],\n",
       "                \"title\": {\n",
       "                    \"line\": \"\\u6298\\u7ebf\\u56fe\",\n",
       "                    \"bar\": \"\\u67f1\\u72b6\\u56fe\",\n",
       "                    \"stack\": \"\\u5806\\u53e0\",\n",
       "                    \"tiled\": \"\\u5e73\\u94fa\"\n",
       "                }\n",
       "            },\n",
       "            \"dataZoom\": {\n",
       "                \"show\": true,\n",
       "                \"title\": {\n",
       "                    \"zoom\": \"\\u533a\\u57df\\u7f29\\u653e\",\n",
       "                    \"back\": \"\\u7f29\\u653e\\u8fd8\\u539f\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 3408803,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u6309\\u5929\\u7edf\\u8ba1\",\n",
       "            \"data\": [\n",
       "                592.0,\n",
       "                706.0,\n",
       "                667.0,\n",
       "                657.0,\n",
       "                385.0,\n",
       "                614.0,\n",
       "                695.0,\n",
       "                717.0,\n",
       "                426.0,\n",
       "                607.0,\n",
       "                339.0,\n",
       "                725.0,\n",
       "                737.0,\n",
       "                526.0,\n",
       "                434.0,\n",
       "                580.0,\n",
       "                447.0,\n",
       "                572.0,\n",
       "                643.0,\n",
       "                480.0,\n",
       "                476.0,\n",
       "                289.0,\n",
       "                529.0,\n",
       "                640.0,\n",
       "                503.0,\n",
       "                487.0,\n",
       "                628.0,\n",
       "                672.0,\n",
       "                448.0,\n",
       "                553.0,\n",
       "                626.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 3408803\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u6309\\u5929\\u7edf\\u8ba1\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"1 \\u65e5\",\n",
       "                \"2 \\u65e5\",\n",
       "                \"3 \\u65e5\",\n",
       "                \"4 \\u65e5\",\n",
       "                \"5 \\u65e5\",\n",
       "                \"6 \\u65e5\",\n",
       "                \"7 \\u65e5\",\n",
       "                \"8 \\u65e5\",\n",
       "                \"9 \\u65e5\",\n",
       "                \"10 \\u65e5\",\n",
       "                \"11 \\u65e5\",\n",
       "                \"12 \\u65e5\",\n",
       "                \"13 \\u65e5\",\n",
       "                \"14 \\u65e5\",\n",
       "                \"15 \\u65e5\",\n",
       "                \"16 \\u65e5\",\n",
       "                \"17 \\u65e5\",\n",
       "                \"18 \\u65e5\",\n",
       "                \"19 \\u65e5\",\n",
       "                \"20 \\u65e5\",\n",
       "                \"21 \\u65e5\",\n",
       "                \"22 \\u65e5\",\n",
       "                \"23 \\u65e5\",\n",
       "                \"24 \\u65e5\",\n",
       "                \"25 \\u65e5\",\n",
       "                \"26 \\u65e5\",\n",
       "                \"27 \\u65e5\",\n",
       "                \"28 \\u65e5\",\n",
       "                \"29 \\u65e5\",\n",
       "                \"30 \\u65e5\",\n",
       "                \"31 \\u65e5\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#546570\",\n",
       "        \"#d48265\",\n",
       "        \"#726930\",\n",
       "        \"#6e7074\",\n",
       "        \"#6950a1\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#bda29a\",\n",
       "        \"#905a3d\",\n",
       "        \"#b2d235\",\n",
       "        \"#2a5caa\",\n",
       "        \"#1d953f\",\n",
       "        \"#f6f5ec\",\n",
       "        \"#f47920\",\n",
       "        \"#fab27b\",\n",
       "        \"#c23531\",\n",
       "        \"#ac6767\",\n",
       "        \"#6d8346\",\n",
       "        \"#444693\",\n",
       "        \"#918597\",\n",
       "        \"#ca8622\",\n",
       "        \"#f05b72\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#749f83\",\n",
       "        \"#ef5b9c\"\n",
       "    ],\n",
       "    \"dataZoom\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"type\": \"slider\",\n",
       "            \"start\": 50,\n",
       "            \"end\": 100,\n",
       "            \"orient\": \"horizontal\"\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "myChart_732f4d7fd79c46989fb4329e905232a0.setOption(option_732f4d7fd79c46989fb4329e905232a0);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x1b924f8b6a0>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['commentTime']=pd.to_datetime(df['commentTime'])\n",
    "df['day'] = df['commentTime'].dt.day\n",
    "df2= df.groupby(['day']).size()\n",
    "df2\n",
    "from pyecharts import  Bar\n",
    "bar =Bar(\"按天统计\",width=1000,height=400)\n",
    "bar.add(\"按天统计\",['{} 日'.format(i) for i in df2.index],df2.values,is_label_show=True, is_datazoom_show=True,is_toolbox_show=True,is_more_utils=True,is_random=True)\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"dcceaad983f54d5cab599efc16e9b7af\" style=\"width:750px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_dcceaad983f54d5cab599efc16e9b7af = echarts.init(document.getElementById('dcceaad983f54d5cab599efc16e9b7af'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_dcceaad983f54d5cab599efc16e9b7af = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6309\\u5468\\u7edf\\u8ba1\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"magicType\": {\n",
       "                \"show\": true,\n",
       "                \"type\": [\n",
       "                    \"line\",\n",
       "                    \"bar\",\n",
       "                    \"stack\",\n",
       "                    \"tiled\"\n",
       "                ],\n",
       "                \"title\": {\n",
       "                    \"line\": \"\\u6298\\u7ebf\\u56fe\",\n",
       "                    \"bar\": \"\\u67f1\\u72b6\\u56fe\",\n",
       "                    \"stack\": \"\\u5806\\u53e0\",\n",
       "                    \"tiled\": \"\\u5e73\\u94fa\"\n",
       "                }\n",
       "            },\n",
       "            \"dataZoom\": {\n",
       "                \"show\": true,\n",
       "                \"title\": {\n",
       "                    \"zoom\": \"\\u533a\\u57df\\u7f29\\u653e\",\n",
       "                    \"back\": \"\\u7f29\\u653e\\u8fd8\\u539f\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 1124305,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u6309\\u5468\\u7edf\\u8ba1\",\n",
       "            \"data\": [\n",
       "                2420.0,\n",
       "                2294.0,\n",
       "                2276.0,\n",
       "                2314.0,\n",
       "                2316.0,\n",
       "                2881.0,\n",
       "                2899.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 1124305\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u6309\\u5468\\u7edf\\u8ba1\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u5468\\u4e00\",\n",
       "                \"\\u5468\\u4e8c\",\n",
       "                \"\\u5468\\u4e09\",\n",
       "                \"\\u5468\\u56db\",\n",
       "                \"\\u5468\\u4e94\",\n",
       "                \"\\u5468\\u516d\",\n",
       "                \"\\u5468\\u65e5\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#2f4554\",\n",
       "        \"#1d953f\",\n",
       "        \"#ac6767\",\n",
       "        \"#bda29a\",\n",
       "        \"#61a0a8\",\n",
       "        \"#f05b72\",\n",
       "        \"#918597\",\n",
       "        \"#6950a1\",\n",
       "        \"#6d8346\",\n",
       "        \"#c23531\",\n",
       "        \"#726930\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#749f83\",\n",
       "        \"#546570\",\n",
       "        \"#905a3d\",\n",
       "        \"#444693\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#ca8622\",\n",
       "        \"#d48265\",\n",
       "        \"#6e7074\",\n",
       "        \"#f47920\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#b2d235\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_dcceaad983f54d5cab599efc16e9b7af.setOption(option_dcceaad983f54d5cab599efc16e9b7af);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x1b928586048>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['commentTime']=pd.to_datetime(df['commentTime'])\n",
    "df['weekday'] = df['commentTime'].dt.weekday\n",
    "df2= df.groupby(['weekday']).size()\n",
    "#  周末吃外卖的还是教平时多了一些\n",
    "from pyecharts import  Bar\n",
    "bar =Bar(\"按周统计\",width=750,height=400)\n",
    "weekday=[\"一\",\"二\",\"三\",\"四\",\"五\",\"六\",\"日\"]\n",
    "bar.add(\"按周统计\",['周{}'.format(i) for i in weekday],df2.values,is_label_show=True, is_datazoom_show=False,is_toolbox_show=True,is_more_utils=True,is_random=True)\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    2018-06-30 14:00:00\n",
       "1    2018-06-30 14:00:00\n",
       "2    2018-06-30 14:00:00\n",
       "3    2018-06-30 14:00:00\n",
       "4    2018-06-30 14:00:00\n",
       "Name: dealEndtime, dtype: object"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 处理数据前需要先处理缺失值\n",
    "# 订单结束时间清洗\n",
    "df['dealEndtime'].fillna(method='ffill').apply(lambda x:time.strftime(\"%Y-%m-%d %H:%M:%S\",time.localtime(x))).head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2人午晚餐                       7640\n",
       "单人午晚餐                       3920\n",
       "学生专享午晚自助                    2638\n",
       "4人午/晚自助                     1581\n",
       "单人下午自助烤肉                     639\n",
       "6人午/晚自助                      507\n",
       "周一至周五自助烤肉/周六日及节假日自助烤肉2选1     209\n",
       "单人午/晚自助                       67\n",
       "周一至周五自助烤肉，免费WiFi              22\n",
       "Name: menu, dtype: int64"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_menu=df['menu'].dropna().astype('category').value_counts()\n",
    "df_menu"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"0af215debe224eabb6eb3a312b1fa308\" style=\"width:1100px;height:500px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_0af215debe224eabb6eb3a312b1fa308 = echarts.init(document.getElementById('0af215debe224eabb6eb3a312b1fa308'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_0af215debe224eabb6eb3a312b1fa308 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u8ba2\\u5355\\u5206\\u5e03\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"magicType\": {\n",
       "                \"show\": true,\n",
       "                \"type\": [\n",
       "                    \"line\",\n",
       "                    \"bar\",\n",
       "                    \"stack\",\n",
       "                    \"tiled\"\n",
       "                ],\n",
       "                \"title\": {\n",
       "                    \"line\": \"\\u6298\\u7ebf\\u56fe\",\n",
       "                    \"bar\": \"\\u67f1\\u72b6\\u56fe\",\n",
       "                    \"stack\": \"\\u5806\\u53e0\",\n",
       "                    \"tiled\": \"\\u5e73\\u94fa\"\n",
       "                }\n",
       "            },\n",
       "            \"dataZoom\": {\n",
       "                \"show\": true,\n",
       "                \"title\": {\n",
       "                    \"zoom\": \"\\u533a\\u57df\\u7f29\\u653e\",\n",
       "                    \"back\": \"\\u7f29\\u653e\\u8fd8\\u539f\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 2775275,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u8ba2\\u5355\\u5206\\u5e03\",\n",
       "            \"data\": [\n",
       "                7640.0,\n",
       "                3920.0,\n",
       "                2638.0,\n",
       "                1581.0,\n",
       "                639.0,\n",
       "                507.0,\n",
       "                209.0,\n",
       "                67.0,\n",
       "                22.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 2775275\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8ba2\\u5355\\u5206\\u5e03\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 10,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2\\u4eba\\u5348\\u665a\\u9910\",\n",
       "                \"\\u5355\\u4eba\\u5348\\u665a\\u9910\",\n",
       "                \"\\u5b66\\u751f\\u4e13\\u4eab\\u81ea\\u52a9\",\n",
       "                \"\\u56db\\u4eba\\u81ea\\u52a9\",\n",
       "                \"6\\u4eba\\u81ea\\u52a9\",\n",
       "                \"\\u5355\\u4eba\\u81ea\\u52a9\\u70e4\\u8089\",\n",
       "                \"\\u81ea\\u52a9\\u70e4\\u80892\\u90091\",\n",
       "                \"\\u5355\\u4eba\\u81ea\\u52a9\",\n",
       "                \"\\u81ea\\u52a9wifi\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_0af215debe224eabb6eb3a312b1fa308.setOption(option_0af215debe224eabb6eb3a312b1fa308);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x1b9285868d0>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import  Bar\n",
    "bar =Bar(\"订单分布\",width=1100,height=500)\n",
    "menu_short=['2人午晚餐','单人午晚餐',\"学生专享自助\",\"四人自助\",\"6人自助\",'单人自助烤肉',\"自助烤肉2选1\",\"单人自助\",\"自助wifi\"]\n",
    "bar.add(\"订单分布\",menu_short,df_menu.values,is_label_show=True, is_datazoom_show=False,is_toolbox_show=True,is_more_utils=True,xaxis_rotate=10)\n",
    "bar\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.059092932032050204"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['readCnt'].corr(df['star'])\n",
    "# 评论阅读书与客户评价分数高低的相关性"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10     329\n",
       "20     533\n",
       "30    2002\n",
       "40    2704\n",
       "50    2072\n",
       "Name: star, dtype: int64"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_most=df[(df[\"menu\"]==\"2人午晚餐\")]['star'].value_counts().reindex(range(10,60,10))\n",
    "df_most"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"7196fe9365694904a9bb0322fe9fae30\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_7196fe9365694904a9bb0322fe9fae30 = echarts.init(document.getElementById('7196fe9365694904a9bb0322fe9fae30'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_7196fe9365694904a9bb0322fe9fae30 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6700\\u53d7\\u6b22\\u8fce\\u5957\\u9910\\u8bc4\\u5206\\u5206\\u5e03\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 3638262,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u6700\\u53d7\\u6b22\\u8fce\\u5957\\u9910\\u8bc4\\u5206\\u5206\\u5e03\",\n",
       "            \"symbol\": \"emptyCircle\",\n",
       "            \"symbolSize\": 4,\n",
       "            \"smooth\": true,\n",
       "            \"step\": false,\n",
       "            \"showSymbol\": true,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"10\",\n",
       "                    329.0\n",
       "                ],\n",
       "                [\n",
       "                    \"20\",\n",
       "                    533.0\n",
       "                ],\n",
       "                [\n",
       "                    \"30\",\n",
       "                    2002.0\n",
       "                ],\n",
       "                [\n",
       "                    \"40\",\n",
       "                    2704.0\n",
       "                ],\n",
       "                [\n",
       "                    \"50\",\n",
       "                    2072.0\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"normal\": {\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 3638262\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u6700\\u53d7\\u6b22\\u8fce\\u5957\\u9910\\u8bc4\\u5206\\u5206\\u5e03\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"10\",\n",
       "                \"20\",\n",
       "                \"30\",\n",
       "                \"40\",\n",
       "                \"50\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_7196fe9365694904a9bb0322fe9fae30.setOption(option_7196fe9365694904a9bb0322fe9fae30);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.line.Line at 0x1b9284f0240>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import Line\n",
    "line =Line(\"最受欢迎套餐评分分布\",width=800,height=400,)\n",
    "line.add(\"最受欢迎套餐评分分布\",[str(i) for i in range(10,60,10)],df_most.values,is_smooth=True,is_label_show=True)\n",
    "line"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "30    1215\n",
       "40    1208\n",
       "50    1093\n",
       "20     298\n",
       "10     106\n",
       "Name: star, dtype: int64"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[(df[\"menu\"]==\"单人午晚餐\")]['star'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "40    954\n",
       "50    863\n",
       "30    529\n",
       "20    191\n",
       "10    101\n",
       "Name: star, dtype: int64"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 学生专享午晚自助 \n",
    "df[(df[\"menu\"]==\"学生专享午晚自助\")]['star'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "50    536\n",
       "30    432\n",
       "40    414\n",
       "10    131\n",
       "20     68\n",
       "Name: star, dtype: int64"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[(df[\"menu\"]==\"4人午/晚自助\")]['star'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "30    208\n",
       "50    169\n",
       "40    144\n",
       "10     98\n",
       "20     20\n",
       "Name: star, dtype: int64"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[(df[\"menu\"]==\"单人下午自助烤肉\")]['star'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "50    245\n",
       "40    142\n",
       "30    112\n",
       "10      8\n",
       "Name: star, dtype: int64"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[(df[\"menu\"]==\"6人午/晚自助\")]['star'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "50    87\n",
       "40    66\n",
       "30    46\n",
       "20    10\n",
       "Name: star, dtype: int64"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#周一至周五自助烤肉/周六日及节假日自助烤肉2选1\n",
    "df[(df[\"menu\"]==\"周一至周五自助烤肉/周六日及节假日自助烤肉2选1\")]['star'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "50    30\n",
       "40    27\n",
       "30    10\n",
       "Name: star, dtype: int64"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[(df[\"menu\"]==\"单人午/晚自助\")]['star'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10     0.0\n",
       "20     0.0\n",
       "30     0.0\n",
       "40     0.0\n",
       "50    22.0\n",
       "Name: star, dtype: float64"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[(df[\"menu\"]==\"周一至周五自助烤肉，免费WiFi\")]['star'].value_counts().reindex(range(10,51,10)).fillna(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "menu                      star\n",
       "2人午晚餐                     10       329\n",
       "                          20       533\n",
       "                          30      2002\n",
       "                          40      2704\n",
       "                          50      2072\n",
       "4人午/晚自助                   10       131\n",
       "                          20        68\n",
       "                          30       432\n",
       "                          40       414\n",
       "                          50       536\n",
       "6人午/晚自助                   10         8\n",
       "                          30       112\n",
       "                          40       142\n",
       "                          50       245\n",
       "单人下午自助烤肉                  10        98\n",
       "                          20        20\n",
       "                          30       208\n",
       "                          40       144\n",
       "                          50       169\n",
       "单人午/晚自助                   30        10\n",
       "                          40        27\n",
       "                          50        30\n",
       "单人午晚餐                     10       106\n",
       "                          20       298\n",
       "                          30      1215\n",
       "                          40      1208\n",
       "                          50      1093\n",
       "周一至周五自助烤肉/周六日及节假日自助烤肉2选1  20        10\n",
       "                          30        46\n",
       "                          40        66\n",
       "                          50        87\n",
       "周一至周五自助烤肉，免费WiFi          50        22\n",
       "学生专享午晚自助                  10       101\n",
       "                          20       191\n",
       "                          30       529\n",
       "                          40       954\n",
       "                          50       863\n",
       "dtype: int64"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# df.groupby(['menu','star']).size().to_excel(\"all_menu_star.xls\")\n",
    "df.groupby(['menu','star']).size()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "star  menu                    \n",
       "10    2人午晚餐                        329\n",
       "      4人午/晚自助                      131\n",
       "      6人午/晚自助                        8\n",
       "      单人下午自助烤肉                      98\n",
       "      单人午晚餐                        106\n",
       "      学生专享午晚自助                     101\n",
       "20    2人午晚餐                        533\n",
       "      4人午/晚自助                       68\n",
       "      单人下午自助烤肉                      20\n",
       "      单人午晚餐                        298\n",
       "      周一至周五自助烤肉/周六日及节假日自助烤肉2选1      10\n",
       "      学生专享午晚自助                     191\n",
       "30    2人午晚餐                       2002\n",
       "      4人午/晚自助                      432\n",
       "      6人午/晚自助                      112\n",
       "      单人下午自助烤肉                     208\n",
       "      单人午/晚自助                       10\n",
       "      单人午晚餐                       1215\n",
       "      周一至周五自助烤肉/周六日及节假日自助烤肉2选1      46\n",
       "      学生专享午晚自助                     529\n",
       "40    2人午晚餐                       2704\n",
       "      4人午/晚自助                      414\n",
       "      6人午/晚自助                      142\n",
       "      单人下午自助烤肉                     144\n",
       "      单人午/晚自助                       27\n",
       "      单人午晚餐                       1208\n",
       "      周一至周五自助烤肉/周六日及节假日自助烤肉2选1      66\n",
       "      学生专享午晚自助                     954\n",
       "50    2人午晚餐                       2072\n",
       "      4人午/晚自助                      536\n",
       "      6人午/晚自助                      245\n",
       "      单人下午自助烤肉                     169\n",
       "      单人午/晚自助                       30\n",
       "      单人午晚餐                       1093\n",
       "      周一至周五自助烤肉/周六日及节假日自助烤肉2选1      87\n",
       "      周一至周五自助烤肉，免费WiFi              22\n",
       "      学生专享午晚自助                     863\n",
       "dtype: int64"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(['star','menu',]).size()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "menu\n",
       "2人午晚餐                       2072\n",
       "4人午/晚自助                      536\n",
       "6人午/晚自助                      245\n",
       "单人下午自助烤肉                     169\n",
       "单人午/晚自助                       30\n",
       "单人午晚餐                       1093\n",
       "周一至周五自助烤肉/周六日及节假日自助烤肉2选1      87\n",
       "周一至周五自助烤肉，免费WiFi              22\n",
       "学生专享午晚自助                     863\n",
       "dtype: int64"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_50=df.groupby(['star','menu',]).size()[50]\n",
    "df_50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"0e3d0d2b8d10441599acdfc4c1692b6c\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_0e3d0d2b8d10441599acdfc4c1692b6c = echarts.init(document.getElementById('0e3d0d2b8d10441599acdfc4c1692b6c'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_0e3d0d2b8d10441599acdfc4c1692b6c = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u8bc4\\u5206\\u6700\\u9ad8\\u7684\\u5957\\u9910\\u5206\\u5e03\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 8070797,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u8bc4\\u5206\\u6700\\u9ad8\\u7684\\u5957\\u9910\\u5206\\u5e03\",\n",
       "            \"data\": [\n",
       "                2072.0,\n",
       "                536.0,\n",
       "                245.0,\n",
       "                169.0,\n",
       "                30.0,\n",
       "                1093.0,\n",
       "                87.0,\n",
       "                22.0,\n",
       "                863.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 8070797\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8bc4\\u5206\\u6700\\u9ad8\\u7684\\u5957\\u9910\\u5206\\u5e03\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2\\u4eba\\u5348\\u665a\\u9910\",\n",
       "                \"\\u5355\\u4eba\\u5348\\u665a\\u9910\",\n",
       "                \"\\u5b66\\u751f\\u4e13\\u4eab\\u81ea\\u52a9\",\n",
       "                \"\\u56db\\u4eba\\u81ea\\u52a9\",\n",
       "                \"6\\u4eba\\u81ea\\u52a9\",\n",
       "                \"\\u5355\\u4eba\\u81ea\\u52a9\\u70e4\\u8089\",\n",
       "                \"\\u81ea\\u52a9\\u70e4\\u80892\\u90091\",\n",
       "                \"\\u5355\\u4eba\\u81ea\\u52a9\",\n",
       "                \"\\u81ea\\u52a9wifi\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_0e3d0d2b8d10441599acdfc4c1692b6c.setOption(option_0e3d0d2b8d10441599acdfc4c1692b6c);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x1b9289d1f28>"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import Bar\n",
    "bar= Bar(\"评分最高的套餐分布\",width=800,height=400,)\n",
    "bar.add(\"评分最高的套餐分布\",menu_short,df_50.values,is_label_show=True)\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "266045270     64\n",
       "152775497     60\n",
       "80372612      60\n",
       "129840082     60\n",
       "336387962     60\n",
       "34216474      60\n",
       "617772217     60\n",
       "82682689      54\n",
       "287219504     49\n",
       "884729389     45\n",
       "868838851     40\n",
       "409054441     40\n",
       "86939815      40\n",
       "776086712     40\n",
       "48597225      40\n",
       "111808598     40\n",
       "240199490     40\n",
       "83068123      40\n",
       "298504911     40\n",
       "1042639014    40\n",
       "912472277     40\n",
       "98198819      40\n",
       "1494880345    40\n",
       "152930400     40\n",
       "139581136     40\n",
       "404183587     40\n",
       "714781743     40\n",
       "292809386     40\n",
       "18111538      40\n",
       "1097689674    40\n",
       "300905323     40\n",
       "232697160     40\n",
       "141718492     40\n",
       "879430090     40\n",
       "696143486     40\n",
       "13257519      40\n",
       "983797146     40\n",
       "911947863     40\n",
       "993057629     40\n",
       "494215297     40\n",
       "Name: userId, dtype: int64"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# userId\n",
    "# 这家店铺有好多回头客，万万没想到\n",
    "df[df['userId']!=0]['userId'].value_counts().head(40)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "xuruiss1026     64\n",
       "vTF610712604    60\n",
       "jIx325233926    60\n",
       "始于初见的你          60\n",
       "么么哒我是你聪叔        60\n",
       "siisgood        60\n",
       "黑发飘呀飘           60\n",
       "yumengkou       54\n",
       "Daaaav          49\n",
       "梁子7543          45\n",
       "TBKLZJ          40\n",
       "Mvo148723747    40\n",
       "bQl271583480    40\n",
       "kingd123        40\n",
       "榴莲馅月饼           40\n",
       "Nqr695642404    40\n",
       "hiP499857883    40\n",
       "oMz861346972    40\n",
       "EqI798548999    40\n",
       "leeman666888    40\n",
       "ihW9198648      40\n",
       "18669978087     40\n",
       "迅行天下            40\n",
       "onr243685128    40\n",
       "yue国光123        40\n",
       "滨海之恋33          40\n",
       "魔方每团            40\n",
       "oUI806055883    40\n",
       "张齐齐123          40\n",
       "小匴盤             40\n",
       "VPA342570392    40\n",
       "FQe845913598    40\n",
       "ree177064067    40\n",
       "liE32679330     40\n",
       "西山仙踪            40\n",
       "清晨cxh98         40\n",
       "andyliu_1983    40\n",
       "SzX539077433    40\n",
       "Mqg827794346    40\n",
       "qDK538313823    40\n",
       "Name: userName, dtype: int64"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df['userName']!=\"匿名用户\"]['userName'].value_counts().head(40)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "star  userLevel\n",
       "10    0             187\n",
       "      1             139\n",
       "      2             164\n",
       "      3             193\n",
       "      4              80\n",
       "      5              10\n",
       "20    0             223\n",
       "      1              88\n",
       "      2             304\n",
       "      3             294\n",
       "      4             207\n",
       "      5              21\n",
       "30    0            1147\n",
       "      1             405\n",
       "      2            1057\n",
       "      3            1230\n",
       "      4             570\n",
       "      5             165\n",
       "      6              20\n",
       "40    0             870\n",
       "      1             432\n",
       "      2            1360\n",
       "      3            1751\n",
       "      4            1026\n",
       "      5             261\n",
       "      6              25\n",
       "50    0             698\n",
       "      1             386\n",
       "      2            1167\n",
       "      3            1670\n",
       "      4             802\n",
       "      5             318\n",
       "      6             130\n",
       "dtype: int64"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(['star','userLevel',]).size()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"0426438b41214004b281d25e5d872413\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_0426438b41214004b281d25e5d872413 = echarts.init(document.getElementById('0426438b41214004b281d25e5d872413'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_0426438b41214004b281d25e5d872413 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u7528\\u6237\\u7b49\\u7ea7\\u4e0e\\u8bc4\\u5206\",\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 7958375,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"level 0\",\n",
       "            \"data\": [\n",
       "                187.0,\n",
       "                223.0,\n",
       "                1147.0,\n",
       "                870.0,\n",
       "                698.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 7958375\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"level 1\",\n",
       "            \"data\": [\n",
       "                139.0,\n",
       "                88.0,\n",
       "                405.0,\n",
       "                432.0,\n",
       "                386.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 7958375\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"level 2\",\n",
       "            \"data\": [\n",
       "                164.0,\n",
       "                304.0,\n",
       "                1057.0,\n",
       "                1360.0,\n",
       "                1167.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 7958375\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"level 3\",\n",
       "            \"data\": [\n",
       "                193.0,\n",
       "                294.0,\n",
       "                1230.0,\n",
       "                1751.0,\n",
       "                1670.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"max\",\n",
       "                        \"name\": \"Maximum\",\n",
       "                        \"symbol\": \"pin\",\n",
       "                        \"symbolSize\": 50,\n",
       "                        \"label\": {\n",
       "                            \"normal\": {\n",
       "                                \"textStyle\": {\n",
       "                                    \"color\": \"#fff\"\n",
       "                                }\n",
       "                            }\n",
       "                        }\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"min\",\n",
       "                        \"name\": \"Minimum\",\n",
       "                        \"symbol\": \"pin\",\n",
       "                        \"symbolSize\": 50,\n",
       "                        \"label\": {\n",
       "                            \"normal\": {\n",
       "                                \"textStyle\": {\n",
       "                                    \"color\": \"#fff\"\n",
       "                                }\n",
       "                            }\n",
       "                        }\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"average\",\n",
       "                        \"name\": \"mean-Value\"\n",
       "                    }\n",
       "                ],\n",
       "                \"symbolSize\": 10\n",
       "            },\n",
       "            \"seriesId\": 7958375\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"level 4\",\n",
       "            \"data\": [\n",
       "                80.0,\n",
       "                207.0,\n",
       "                570.0,\n",
       "                1026.0,\n",
       "                802.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 7958375\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"level 5\",\n",
       "            \"data\": [\n",
       "                10.0,\n",
       "                21.0,\n",
       "                165.0,\n",
       "                261.0,\n",
       "                318.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 7958375\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"level 6\",\n",
       "            \"data\": [\n",
       "                0.0,\n",
       "                0.0,\n",
       "                20.0,\n",
       "                25.0,\n",
       "                130.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 7958375\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"level 0\",\n",
       "                \"level 1\",\n",
       "                \"level 2\",\n",
       "                \"level 3\",\n",
       "                \"level 4\",\n",
       "                \"level 5\",\n",
       "                \"level 6\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"right\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                10.0,\n",
       "                20.0,\n",
       "                30.0,\n",
       "                40.0,\n",
       "                50.0\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_0426438b41214004b281d25e5d872413.setOption(option_0426438b41214004b281d25e5d872413);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x1b928b2efd0>"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_level_star = df.groupby(['userLevel','star']).size()\n",
    "attr = np.arange(10,60,10)\n",
    "\n",
    "from pyecharts import Bar\n",
    "bar = Bar(\"用户等级与评分\",title_pos=\"center\")\n",
    "df_0 = df_level_star[0].values\n",
    "df_1 = df_level_star[1].values\n",
    "df_2 = df_level_star[2].values\n",
    "df_3 = df_level_star[3].values\n",
    "df_4 = df_level_star[4].values\n",
    "df_5 = df_level_star[5].values\n",
    "# df_6 = df_level_star[6].values\n",
    "df_6 = df_level_star[6].reindex(attr).fillna(0).values\n",
    "\n",
    "bar.add(\"level 0\",attr,df_0,is_label_show=True,legend_pos='right',legend_orient='vertical',label_text_size=12)\n",
    "bar.add(\"level 1\",attr,df_1,is_label_show=True,legend_pos='right',legend_orient='vertical',label_text_size=12)\n",
    "bar.add(\"level 2\",attr,df_2,is_label_show=True,legend_pos='right',legend_orient='vertical',label_text_size=12)\n",
    "bar.add(\"level 3\",attr,df_3,mark_line=[\"average\"],mark_point=['max','min'],is_label_show=True,legend_pos='right',legend_orient='vertical',label_text_size=12)\n",
    "bar.add(\"level 4\",attr,df_4,is_label_show=True,legend_pos='right',legend_orient='vertical',label_text_size=12)\n",
    "bar.add(\"level 5\",attr,df_5,is_label_show=True,legend_pos='right',legend_orient='vertical',label_text_size=12)\n",
    "bar.add(\"level 6\",attr,df_6,is_label_show=True,legend_pos='right',legend_orient='vertical',label_text_size=12)\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"da4201e73dd44f229e896a9b0978e04b\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_da4201e73dd44f229e896a9b0978e04b = echarts.init(document.getElementById('da4201e73dd44f229e896a9b0978e04b'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_da4201e73dd44f229e896a9b0978e04b = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u7528\\u6237\\u7b49\\u7ea7\\u4e0e\\u8bc4\\u5206\",\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"color\": \"red\",\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 938326,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"level 0\",\n",
       "            \"data\": [\n",
       "                187.0,\n",
       "                223.0,\n",
       "                1147.0,\n",
       "                870.0,\n",
       "                698.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": false,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 938326\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"level 1\",\n",
       "            \"data\": [\n",
       "                139.0,\n",
       "                88.0,\n",
       "                405.0,\n",
       "                432.0,\n",
       "                386.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": false,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 938326\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"level 2\",\n",
       "            \"data\": [\n",
       "                164.0,\n",
       "                304.0,\n",
       "                1057.0,\n",
       "                1360.0,\n",
       "                1167.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": false,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 938326\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"level 3\",\n",
       "            \"data\": [\n",
       "                193.0,\n",
       "                294.0,\n",
       "                1230.0,\n",
       "                1751.0,\n",
       "                1670.0\n",
       "            ],\n",
       "            \"stack\": \"stack_938326\",\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": false,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 938326\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"level 4\",\n",
       "            \"data\": [\n",
       "                80.0,\n",
       "                207.0,\n",
       "                570.0,\n",
       "                1026.0,\n",
       "                802.0\n",
       "            ],\n",
       "            \"stack\": \"stack_938326\",\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": false,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 938326\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"level 5\",\n",
       "            \"data\": [\n",
       "                10.0,\n",
       "                21.0,\n",
       "                165.0,\n",
       "                261.0,\n",
       "                318.0\n",
       "            ],\n",
       "            \"stack\": \"stack_938326\",\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": false,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 938326\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"level 6\",\n",
       "            \"data\": [\n",
       "                0.0,\n",
       "                0.0,\n",
       "                20.0,\n",
       "                25.0,\n",
       "                130.0\n",
       "            ],\n",
       "            \"stack\": \"stack_938326\",\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": false,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 938326\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"level 0\",\n",
       "                \"level 1\",\n",
       "                \"level 2\",\n",
       "                \"level 3\",\n",
       "                \"level 4\",\n",
       "                \"level 5\",\n",
       "                \"level 6\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"right\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                10.0,\n",
       "                20.0,\n",
       "                30.0,\n",
       "                40.0,\n",
       "                50.0\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_da4201e73dd44f229e896a9b0978e04b.setOption(option_da4201e73dd44f229e896a9b0978e04b);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x1b928b33320>"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bar = Bar(\"用户等级与评分\",title_pos=\"center\",title_color=\"red\")\n",
    "attr = np.arange(10,60,10)\n",
    "df_0 = df_level_star[0].values\n",
    "df_1 = df_level_star[1].values\n",
    "df_2 = df_level_star[2].values\n",
    "df_3 = df_level_star[3].values\n",
    "df_4 = df_level_star[4].values\n",
    "df_5 = df_level_star[5].values\n",
    "# df_6 = df_level_star[6].values\n",
    "df_6 = df_level_star[6].reindex(attr).fillna(0).values\n",
    "bar.add(\"level 0\",attr,df_0,legend_pos='right',legend_orient='vertical',label_text_size=12)\n",
    "bar.add(\"level 1\",attr,df_1,legend_pos='right',legend_orient='vertical',label_text_size=12)\n",
    "bar.add(\"level 2\",attr,df_2,legend_pos='right',legend_orient='vertical',label_text_size=12)\n",
    "bar.add(\"level 3\",attr,df_3,is_stack=True,legend_pos='right',legend_orient='vertical',label_text_size=12)\n",
    "bar.add(\"level 4\",attr,df_4,is_stack=True,legend_pos='right',legend_orient='vertical',label_text_size=12)\n",
    "bar.add(\"level 5\",attr,df_5,is_stack=True,legend_pos='right',legend_orient='vertical',label_text_size=12)\n",
    "bar.add(\"level 6\",attr,df_6,is_stack=True,legend_pos='right',legend_orient='vertical',label_text_size=12)\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.14389808871897797"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['star'].corr(df['userLevel'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"1dc284933220432195fac8361e12e4f2\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_1dc284933220432195fac8361e12e4f2 = echarts.init(document.getElementById('1dc284933220432195fac8361e12e4f2'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_1dc284933220432195fac8361e12e4f2 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u70b9\\u8d5e\\u7edf\\u8ba1\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 5182110,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u70b9\\u8d5e\\u5206\\u5e03\",\n",
       "            \"data\": [\n",
       "                652.0,\n",
       "                143.0,\n",
       "                119.0,\n",
       "                20.0,\n",
       "                20.0,\n",
       "                20.0,\n",
       "                4.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 5182110\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u70b9\\u8d5e\\u5206\\u5e03\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                1.0,\n",
       "                2.0,\n",
       "                3.0,\n",
       "                8.0,\n",
       "                6.0,\n",
       "                4.0,\n",
       "                5.0\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_1dc284933220432195fac8361e12e4f2.setOption(option_1dc284933220432195fac8361e12e4f2);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x1b928b2e9e8>"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_zan=df['zanCnt'].value_counts()\n",
    "from pyecharts import Bar\n",
    "bar=Bar(\"点赞统计\")\n",
    "bar.add(\"点赞分布\",df_zan.index[1:],df_zan.values[1:],is_label_show=True)\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>avgPrice</th>\n",
       "      <th>dealEndtime</th>\n",
       "      <th>did</th>\n",
       "      <th>readCnt</th>\n",
       "      <th>replyCnt</th>\n",
       "      <th>reviewId</th>\n",
       "      <th>star</th>\n",
       "      <th>userId</th>\n",
       "      <th>userLevel</th>\n",
       "      <th>zanCnt</th>\n",
       "      <th>hour</th>\n",
       "      <th>day</th>\n",
       "      <th>weekday</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>17400.0</td>\n",
       "      <td>1.722300e+04</td>\n",
       "      <td>1.740000e+04</td>\n",
       "      <td>17400.000000</td>\n",
       "      <td>17400.000000</td>\n",
       "      <td>1.740000e+04</td>\n",
       "      <td>17400.000000</td>\n",
       "      <td>1.740000e+04</td>\n",
       "      <td>17400.000000</td>\n",
       "      <td>17400.000000</td>\n",
       "      <td>17400.000000</td>\n",
       "      <td>17400.000000</td>\n",
       "      <td>17400.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>73.0</td>\n",
       "      <td>1.529633e+09</td>\n",
       "      <td>4.376319e+07</td>\n",
       "      <td>1622.936149</td>\n",
       "      <td>0.032759</td>\n",
       "      <td>1.443980e+09</td>\n",
       "      <td>37.691954</td>\n",
       "      <td>3.224900e+08</td>\n",
       "      <td>2.335230</td>\n",
       "      <td>0.096264</td>\n",
       "      <td>14.955460</td>\n",
       "      <td>15.603506</td>\n",
       "      <td>3.152356</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>0.0</td>\n",
       "      <td>5.730086e+06</td>\n",
       "      <td>5.749815e+06</td>\n",
       "      <td>4981.816447</td>\n",
       "      <td>0.260349</td>\n",
       "      <td>2.208396e+08</td>\n",
       "      <td>10.813002</td>\n",
       "      <td>3.914649e+08</td>\n",
       "      <td>1.470979</td>\n",
       "      <td>0.511591</td>\n",
       "      <td>5.046872</td>\n",
       "      <td>9.131639</td>\n",
       "      <td>2.044944</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>73.0</td>\n",
       "      <td>1.483078e+09</td>\n",
       "      <td>1.330754e+06</td>\n",
       "      <td>20.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.093178e+09</td>\n",
       "      <td>10.000000</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>73.0</td>\n",
       "      <td>1.530338e+09</td>\n",
       "      <td>4.432824e+07</td>\n",
       "      <td>162.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.197515e+09</td>\n",
       "      <td>30.000000</td>\n",
       "      <td>4.527015e+07</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>11.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>73.0</td>\n",
       "      <td>1.530338e+09</td>\n",
       "      <td>4.432824e+07</td>\n",
       "      <td>304.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.606347e+09</td>\n",
       "      <td>40.000000</td>\n",
       "      <td>1.527755e+08</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>15.000000</td>\n",
       "      <td>15.000000</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>73.0</td>\n",
       "      <td>1.530338e+09</td>\n",
       "      <td>4.432853e+07</td>\n",
       "      <td>751.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.646467e+09</td>\n",
       "      <td>50.000000</td>\n",
       "      <td>4.859086e+08</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>19.000000</td>\n",
       "      <td>24.000000</td>\n",
       "      <td>5.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>73.0</td>\n",
       "      <td>1.530338e+09</td>\n",
       "      <td>4.597465e+07</td>\n",
       "      <td>77837.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>1.698204e+09</td>\n",
       "      <td>50.000000</td>\n",
       "      <td>1.771740e+09</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>23.000000</td>\n",
       "      <td>31.000000</td>\n",
       "      <td>6.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       avgPrice   dealEndtime           did       readCnt      replyCnt  \\\n",
       "count   17400.0  1.722300e+04  1.740000e+04  17400.000000  17400.000000   \n",
       "mean       73.0  1.529633e+09  4.376319e+07   1622.936149      0.032759   \n",
       "std         0.0  5.730086e+06  5.749815e+06   4981.816447      0.260349   \n",
       "min        73.0  1.483078e+09  1.330754e+06     20.000000      0.000000   \n",
       "25%        73.0  1.530338e+09  4.432824e+07    162.000000      0.000000   \n",
       "50%        73.0  1.530338e+09  4.432824e+07    304.000000      0.000000   \n",
       "75%        73.0  1.530338e+09  4.432853e+07    751.000000      0.000000   \n",
       "max        73.0  1.530338e+09  4.597465e+07  77837.000000      4.000000   \n",
       "\n",
       "           reviewId          star        userId     userLevel        zanCnt  \\\n",
       "count  1.740000e+04  17400.000000  1.740000e+04  17400.000000  17400.000000   \n",
       "mean   1.443980e+09     37.691954  3.224900e+08      2.335230      0.096264   \n",
       "std    2.208396e+08     10.813002  3.914649e+08      1.470979      0.511591   \n",
       "min    1.093178e+09     10.000000  0.000000e+00      0.000000      0.000000   \n",
       "25%    1.197515e+09     30.000000  4.527015e+07      1.000000      0.000000   \n",
       "50%    1.606347e+09     40.000000  1.527755e+08      3.000000      0.000000   \n",
       "75%    1.646467e+09     50.000000  4.859086e+08      3.000000      0.000000   \n",
       "max    1.698204e+09     50.000000  1.771740e+09      6.000000      8.000000   \n",
       "\n",
       "               hour           day       weekday  \n",
       "count  17400.000000  17400.000000  17400.000000  \n",
       "mean      14.955460     15.603506      3.152356  \n",
       "std        5.046872      9.131639      2.044944  \n",
       "min        0.000000      1.000000      0.000000  \n",
       "25%       11.000000      8.000000      1.000000  \n",
       "50%       15.000000     15.000000      3.000000  \n",
       "75%       19.000000     24.000000      5.000000  \n",
       "max       23.000000     31.000000      6.000000  "
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    3125\n",
       "1    1450\n",
       "2    4052\n",
       "3    5138\n",
       "4    2685\n",
       "5     775\n",
       "6     175\n",
       "Name: userLevel, dtype: int64"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['userLevel'].value_counts().reindex(range(7))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"955bb86dcb524e15b7d9c5004fdd212f\" style=\"width:900px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_955bb86dcb524e15b7d9c5004fdd212f = echarts.init(document.getElementById('955bb86dcb524e15b7d9c5004fdd212f'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_955bb86dcb524e15b7d9c5004fdd212f = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u7528\\u6237\\u7b49\\u7ea7\\u5206\\u5e03\",\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 7723560,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"name\": \"levels distribution\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"level 0\",\n",
       "                    \"value\": 3125.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"level 1\",\n",
       "                    \"value\": 1450.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"level 2\",\n",
       "                    \"value\": 4052.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"level 3\",\n",
       "                    \"value\": 5138.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"level 4\",\n",
       "                    \"value\": 2685.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"level 5\",\n",
       "                    \"value\": 775.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"level 6\",\n",
       "                    \"value\": 175.0\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"0%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"roseType\": \"area\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"outside\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 20\n",
       "                    },\n",
       "                    \"formatter\": \"{b}: {d}%\"\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    },\n",
       "                    \"formatter\": \"{b}: {d}%\"\n",
       "                }\n",
       "            },\n",
       "            \"seriesId\": 7723560\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"level 0\",\n",
       "                \"level 1\",\n",
       "                \"level 2\",\n",
       "                \"level 3\",\n",
       "                \"level 4\",\n",
       "                \"level 5\",\n",
       "                \"level 6\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"left\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#ca8622\",\n",
       "        \"#2a5caa\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#749f83\",\n",
       "        \"#bda29a\",\n",
       "        \"#c23531\",\n",
       "        \"#f6f5ec\",\n",
       "        \"#2f4554\",\n",
       "        \"#444693\",\n",
       "        \"#ac6767\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#918597\",\n",
       "        \"#6e7074\",\n",
       "        \"#6d8346\",\n",
       "        \"#61a0a8\",\n",
       "        \"#726930\",\n",
       "        \"#f47920\",\n",
       "        \"#b2d235\",\n",
       "        \"#546570\",\n",
       "        \"#f05b72\",\n",
       "        \"#fab27b\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#905a3d\",\n",
       "        \"#d48265\"\n",
       "    ]\n",
       "};\n",
       "myChart_955bb86dcb524e15b7d9c5004fdd212f.setOption(option_955bb86dcb524e15b7d9c5004fdd212f);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.pie.Pie at 0x1b928b2cc18>"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_level=df['userLevel'].value_counts().reindex(range(7))\n",
    "from pyecharts import Pie\n",
    "pie=Pie(\"用户等级分布\",title_pos=\"center\",width=900)\n",
    "pie.add(\"levels distribution\",[\"level \"+str(i) for i in range(7)],df_level.values,is_random=True,radidus=[30,45],legend_pos='left',rosetype='area',legend_orient='vertical',is_label_show=True,label_text_size=20)\n",
    "pie"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Raw Cell Format",
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
